import 'package:flutter/material.dart';

import '../global_config.dart';

class SearchPage extends StatefulWidget {
  @override
  _SearchPageState createState() => _SearchPageState();
}

class _SearchPageState extends State<SearchPage> {
  Widget searchBar() {
    return new Container(
      decoration: new BoxDecoration(
          borderRadius: new BorderRadius.all(Radius.circular(4.0)),
          color: GlobalConfig.searchBackgroundColor),
      child: new Row(
        children: <Widget>[
          new Container(
            width: 60,
            child: new FlatButton.icon(
              onPressed: () {
                Navigator.of(context).pop();
              },
              icon: new Icon(
                Icons.arrow_back,
                color: GlobalConfig.fontColor,
              ),
              label: new Text(""),
            ),
          ),
          new Expanded(
              child: new TextField(
            autofocus: true,
            decoration: new InputDecoration.collapsed(
                hintText: "搜索比乎内容",
                hintStyle: new TextStyle(color: GlobalConfig.fontColor)),
          ))
        ],
      ),
    );
  }

  @override
  Widget build(BuildContext context) {
    return new MaterialApp(
      theme: GlobalConfig.themeData,
      home: new Scaffold(
        appBar: new AppBar(
          title: searchBar(),
        ),
        body: new SingleChildScrollView(
          child: new Column(
            children: <Widget>[
              new Container(
                child: new Text(
                  "比乎热搜",
                  style:
                      new TextStyle(fontSize: 16, fontWeight: FontWeight.bold),
                ),
                padding:
                    const EdgeInsets.only(left: 16.0, top: 16.0, bottom: 16.0),
                alignment: Alignment.centerLeft,
              ),
              new Row(
                children: <Widget>[
                  new Container(
                    child: new Chip(
                      label: new FlatButton(onPressed: (){}, child: new Text("汽车关税下调",style: new TextStyle(color: GlobalConfig.fontColor),)),
                      backgroundColor: GlobalConfig.dark == true ? Colors.white10 : Colors.black12,
                    ),
                    margin: const EdgeInsets.only(left: 16.0, bottom: 16.0),
                    alignment: Alignment.topLeft,
                  ),
                  new Container(
                    child: new Chip(
                      label: new FlatButton(onPressed: (){}, child: new Text("李彦宏传闻辟谣",style: new TextStyle(color: GlobalConfig.fontColor))),
                      backgroundColor: GlobalConfig.dark == true ? Colors.white10 : Colors.black12,
                    ),
                    margin: const EdgeInsets.only(left: 16.0, bottom: 16.0),
                    alignment: Alignment.topLeft,
                  ),
                ],
              ),
              new Row(
                children: <Widget>[
                  new Container(
                    child: new Chip(
                      label: new FlatButton(onPressed: (){}, child: new Text("小米8",style: new TextStyle(color: GlobalConfig.fontColor))),
                      backgroundColor: GlobalConfig.dark == true ? Colors.white10 : Colors.black12,
                    ),
                    margin: const EdgeInsets.only(left: 16.0, bottom: 16.0),
                    alignment: Alignment.topLeft,
                  ),
                  new Container(
                    child: new Chip(
                      label: new FlatButton(onPressed: (){}, child: new Text("超时空同居",style: new TextStyle(color: GlobalConfig.fontColor))),
                      backgroundColor: GlobalConfig.dark == true ? Colors.white10 : Colors.black12,
                    ),
                    margin: const EdgeInsets.only(left: 16.0, bottom: 16.0),
                    alignment: Alignment.topLeft,
                  ),
                ],
              ),
              new Container(
                child: new Text("搜索历史", style: new TextStyle(fontWeight: FontWeight.bold, fontSize: 16.0)),
                margin: const EdgeInsets.only(left: 16.0, bottom: 16.0),
                alignment: Alignment.topLeft,
              ),
              new Container(
                child: new Row(
                  children: <Widget>[
                    new Container(
                      child: new Icon(Icons.access_time, color: GlobalConfig.fontColor, size: 16.0),
                      margin: const EdgeInsets.only(right: 12.0),
                    ),
                    new Expanded(
                      child: new Container(
                        child: new Text("业余兴趣", style: new TextStyle( color: GlobalConfig.fontColor, fontSize: 14.0),),
                      ),
                    ),
                    new Container(
                      child: new Icon(Icons.clear, color: GlobalConfig.fontColor, size: 16.0),
                    )
                  ],
                ),
                margin: const EdgeInsets.only(left: 16.0, right: 16.0, bottom: 10.0),
                padding: const EdgeInsets.only(bottom: 10.0),
                decoration: new BoxDecoration(
                    border: new BorderDirectional(bottom: new BorderSide(color: GlobalConfig.dark == true ?  Colors.white12 : Colors.black12))
                ),
              ),
              new Container(
                child: new Row(
                  children: <Widget>[
                    new Container(
                      child: new Icon(Icons.access_time, color: GlobalConfig.fontColor, size: 16.0),
                      margin: const EdgeInsets.only(right: 12.0),
                    ),
                    new Expanded(
                      child: new Container(
                        child: new Text("三体", style: new TextStyle( color: GlobalConfig.fontColor, fontSize: 14.0),),
                      ),
                    ),
                    new Container(
                      child: new Icon(Icons.clear, color: GlobalConfig.fontColor, size: 16.0),
                    )
                  ],
                ),
                margin: const EdgeInsets.only(left: 16.0, right: 16.0, bottom: 10.0),
                padding: const EdgeInsets.only(bottom: 10.0),
                decoration: new BoxDecoration(
                    border: new BorderDirectional(bottom: new BorderSide(color: GlobalConfig.dark == true ?  Colors.white12 : Colors.black12))
                ),
              ),
              new Container(
                child: new Row(
                  children: <Widget>[
                    new Container(
                      child: new Icon(Icons.access_time, color: GlobalConfig.fontColor, size: 16.0),
                      margin: const EdgeInsets.only(right: 12.0),
                    ),
                    new Expanded(
                      child: new Container(
                        child: new Text("人类未来", style: new TextStyle( color: GlobalConfig.fontColor, fontSize: 14.0),),
                      ),
                    ),
                    new Container(
                      child: new Icon(Icons.clear, color: GlobalConfig.fontColor, size: 16.0),
                    )
                  ],
                ),
                margin: const EdgeInsets.only(left: 16.0, right: 16.0, bottom: 10.0),
                padding: const EdgeInsets.only(bottom: 10.0),
                decoration: new BoxDecoration(
                    border: new BorderDirectional(bottom: new BorderSide(color: GlobalConfig.dark == true ?  Colors.white12 : Colors.black12))
                ),
              ),
            ],
          ),
        ),
      ),
    );
  }
}
